Method and terminal for generating a text based on self-encoding neural network, and medium

ABSTRACT

The present disclosure relates to the technical field of natural language understanding, and provides a method, a terminal and a medium for generating a text based on a self-encoding neural network. The method includes: obtaining a text word vector and a classification requirement of a statement to be input; reversely inputting the text word vector into a trained self-encoding neural network model to obtain a hidden feature of an intermediate hidden layer of the self-encoding neural network model; modifying the hidden feature according to a preset classification scale and the classification requirement; defining the modified hidden feature as the intermediate hidden layer of the self-encoding neural network model, and reversely generating a word vector corresponding to an input layer of the self-encoding neural network model by the intermediate hidden layer; and generating the corresponding text, according to the generated word vector.

The present disclosure claims the priority of Chinese Patent ApplicationNo. 201811526185.4, entitled “METHOD, DEVICE, AND TERMINAL FORGENERATION A TEXT BASED ON SELF-ENCODING NEURAL NETWORK, AND MEDIUM”,filed on Dec. 13, 2018, which is hereby incorporated by reference in itsentirety.

TECHNICAL FIELD

The present disclosure relates to the technical field of naturallanguage understanding, in particular to a method, a device, and aterminal for generating a text based on a self-encoding neural network,and a medium.

BACKGROUND

Automatic text generation is an important research aspect in the fieldof natural language processing. Realizing the automatic text generationis also an important maturity sign of artificial intelligence. The textgeneration applications can be divided into supervised text generationapplication and unsupervised text generation application. The supervisedtext generation application includes machine translation, intelligentquestion answering system, dialogue system, and text summarization. Theunsupervised text generation application, such as poetry creation andmusical creation, etc., is configured to learn the original datadistribution, then generate the sample which is similar to the originaldata. Through the text generation, the human-computer interactionprocess would become more intelligent and natural. And the news can bewritten and published automatically through replacing human editors withthe automatic text generation system.

However, the existing text generation model, such as the adversarialgeneration model, requires a large amount of data annotation resourcesand modeling resources.

SUMMARY

The main objective of the present disclosure is to provide a method, adevice, and a terminal for generating a text based on a self-encodingneural network, and a medium, aiming at solving the technical issuesthat in the related art a large amount of data annotation resources andmodeling resources are required to generate the text model.

In order to achieve the above objective, the present disclosure providesa method for generating a text based on a self-encoding neural network,including the following operations:

obtaining a text word vector and a classification requirement of astatement to be input;

reversely inputting the text word vector into a trained self-encodingneural network model to obtain a hidden feature of an intermediatehidden layer of the self-encoding neural network model;

modifying the hidden feature according to a preset classification scaleand the classification requirement;

defining the modified hidden feature as the intermediate hidden layer ofthe self-encoding neural network model, and reversely generating a wordvector corresponding to an input layer of the self-encoding neuralnetwork model by the intermediate hidden layer; and

generating the corresponding text, according to the generated wordvector.

In order to achieve the above objective, the present disclosure furtherprovides a device for generating a text based on a self-encoding neuralnetwork, including:

an obtaining module, configured to obtain a text word vector of a inputstatement and of a classification requirement;

an inputting module, configured to reversely input the text word vectorinto a trained self-encoding neural network model reversely to obtain ahidden feature of an intermediate hidden layer of the self-encodingneural network model;

a modifying module, configured to modify the hidden feature according toa preset classification scale and the classification requirement;

a decoding module, configured to define the modified hidden feature asthe intermediate hidden layer of the self-encoding neural network model,and reversely generate a word vector corresponding to an input layer ofthe self-encoding neural network model by the intermediate hidden layer;

a generating module, configured to generate the corresponding text,according to the generated word vector.

In order to achieve the above objective, the present disclosure furtherprovides a terminal, the terminal includes: a processor, a memory, and acomputer-readable instruction for generating a text based on aself-encoding neural network. The instruction is stored on the memoryand executable on the processor, the instruction is configured toimplement the operations of the method for generating a text based on aself-encoding neural network above-mentioned.

In order to achieve the above objective, the present disclosure furtherprovides a storage medium which stores a computer-readable instructionbased on the self-encoding neural network for generating text, theinstruction when executed by the processor performs operations of themethod described above.

The present disclosure obtains the text word vector and theclassification requirement of the statement to be input, and reverselyinputs the text word vector into the trained self-encoding neuralnetwork model to obtain the hidden feature of the intermediate hiddenlayer of the self-encoding neural network model. The hidden feature ismodified according to the preset classification scale and classificationrequirement. The modified hidden feature is defined as the intermediatehidden layer of the self-encoding neural network model. The word vectorcorresponding to the input layer of the self-encoding neural network isreversely generated through the intermediate hidden layer, the text isgenerated according to the generated word vector. The text generationstyle is adjusted according to the preset classification scale and theclassification requirements, without consuming a large amount of dataannotation resources and modeling resources.

BRIEF DESCRIPTION OF THE ACCOMPANYING DRAWINGS

FIG. 1 is a schematic structural diagram of a terminal in a hardwareoperating environment according to an embodiment of the presentdisclosure;

FIG. 2 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a first embodiment of thepresent disclosure;

FIG. 3 is a schematic structural diagram of a self-encoding neuralnetwork training model according to an embodiment of the presentdisclosure;

FIG. 4 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a second embodiment ofthe present disclosure;

FIG. 5 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a third embodiment of thepresent disclosure;

FIG. 6 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a fourth embodiment ofthe present disclosure;

FIG. 7 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a fifth embodiment of thepresent disclosure;

FIG. 8 is a structural block diagram of a device for generating a textbased on a self-encoding neural network according to a first embodimentof the present disclosure.

The implementation, functional feature and advantages of the presentdisclosure will be further described with reference to the attacheddrawings in combination with embodiments.

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

It will be appreciated that the specific embodiments described hereinare merely illustrative of the present disclosure and are not intendedto limit the disclosure.

Referring to FIG. 1, FIG. 1 is a schematic structural diagram of aterminal in a hardware operating environment according to an embodimentof the present disclosure.

Referring to FIG. 1, the terminal may include a processor 1001, such asa central processing unit (CPU), a communication bus 1002, a userinterface 1003, a network interface 1004, and a memory 1005. And thecommunication bus 1002 being configured to implement connection andcommunication among these modules. The user interface 1003 may include adisplay, an input module such as a keyboard, and the optional userinterface 1003 may further include a standard wired interface and awireless interface. The network interface 1004 may optionally includethe standard wired interface and the wireless interface (such as aWireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a highspeed Random Access Memory (RAM) memory or a non-volatile memory, suchas a disk memory. The memory 1005 can also optionally be a storagedevice which is independent of the aforementioned processor 1001.

It should be understood by those skilled in the art that the structureillustrated in FIG. 1 does not intended to limit the terminal of thepresent disclosure, and may include more or less modules than thoseillustrated, or include a combination of certain modules, or include anarrangement of different modules.

Referring to FIG. 1, the memory 1005 as a storage medium may include anoperating system, a data storage module, a network communication module,a user interface module, and a computer-readable instruction forgenerating a text based on a self-encoding neural network.

In the terminal as shown in FIG. 1, the network interface 1004 is mainlyconfigured to perform the data communication with the network server.The user interface 1003 is mainly configured to perform the datainteraction with the user. The processor 1001 and the memory 1005 of thepresent disclosure may be set in the terminal. The terminal isconfigured to call the instruction stored on the memory 1005 through theprocessor 1001, and perform operations of the method provided in theembodiments of the present disclosure.

An embodiment of the present disclosure provides a method for generatinga text based on the self-encoding neural network. Referring to FIG. 2,FIG. 2 is a schematic flowchart of a method for generating a text basedon a self-encoding neural network according to a first embodiment of thepresent disclosure.

In the embodiment, the method includes the following operations:

Operation S10: obtaining a text word vector and a classificationrequirement of a statement to be input;

It should be noted that the execution subject of the method in thepresent embodiment is a terminal. And the classification requirementgenerally refers to the desired classification category. Taking anevaluation text as an example, which can be divided into two categoriesthat includes a positive evaluation and a negative evaluation. Theclassification requirements may be an expectation to output the negativeevaluation, or an expectation to output the positive evaluation. Takingan emotional text as another example, which can be divided into apositive emotion and a negative emotion. And taking a friendship text asan example, it can be divided into very friendly, more friendly,generally friendly, and unfriendly. The classification requirement maybe obtained by user-defined input, or may be preset, which is notspecifically limited herein.

In a specific embodiment, the operations of “obtaining a text wordvector of a statement to be input”, specifically includes: obtaining theinput statement, preprocessing the input statement and obtaining thetext word vector of the preprocessed input statement.

The process of preprocessing the input statement generally includes:removing a stop word. The stop word refers to a word which appearsmultiple times and has little effect on the text, such as Chinesecharacter “

”, “

”, “

”, etc., or the Hyper Text Markup Language (HTML) tag and the scriptinglanguage in the web page data set, etc.

For example, if the input text is doc, the corresponding text wordvectors are {ω1, ω2, . . . ωi}, in which oi is the word vector of thei^(th) word in the statement.

Operation S20: reversely inputting the text word vector into a trainedself-encoding neural network model to obtain a hidden feature of anintermediate hidden layer of the self-encoding neural network model;

It should be noted that the operation of reversely inputting the textword vector into a trained self-encoding neural network model to obtaina hidden feature of an intermediate hidden layer of the self-encodingneural network model means that the text word vector is configured asthe output vector of the trained self-encoding neural network model toobtain the hidden feature of the intermediate hidden layer reversely(Referring to FIG. 3, FIG. 3 is the situation that the self-encodingneural network model includes one hidden layer, the text word vector isinput into the output layer to obtain the hidden feature of the hiddenlayer located between the input layer and the output layer). When theself-encoding neural network model has multiple hidden layers, thehidden feature obtained of the middlemost hidden layer is taken as thehidden feature of the intermediate hidden layer. For example, when theself-encoding neural network model has three hidden layers, the hiddenfeature obtained by the second middle layer is taken as the hiddenfeature of the intermediate hidden layer; or when the intermediatehidden layers has two hidden layers, an average value of the hiddenfeatures corresponding to the two hidden layers is taken as the hiddenfeature of the intermediate hidden layer, and so on. When theintermediate hidden layer is an odd-numbered layer, the hidden featureobtained by the middlemost hidden layer is taken as the hidden featureof the intermediate hidden layer. When the intermediate hidden layer isan even-numbered layer, the average value of the hidden features of thetwo middlemost hidden layers is taken as the hidden feature of theintermediate hidden layer.

In a specific embodiment, the operation of “reversely inputting the textword vector into a trained self-encoding neural network model reverselyto obtain a hidden feature of an intermediate hidden layer of theself-encoding neural network model”, includes:

inputting the text word vector into an output layer of the trainedself-encoding neural network model, and inversely generating a hiddenfeature of the intermediate hidden layer of the self-encoding neuralnetwork model by the output layer, and defining the hidden feature asthe hidden feature of the intermediate hidden layer of the self-encodingneural network model; and

taking the hidden feature corresponding to the middlemost layer of theintermediate hidden layers as the hidden feature of the intermediatehidden layer of the self-encoding neural network model, in response to adetermination that the self-encoding neural network model includes anodd number of intermediate hidden layers; or

taking an average value of the hidden features corresponding to twomiddlemost layers of the intermediate hidden layers as the hiddenfeature of the intermediate hidden layer of the self-encoding neuralnetwork model, in response to a determination that the self-encodingneural network model includes an even number of intermediate hiddenlayers.

The training process of the self-encoding neural network model includes:

Pre-training, a first hidden layer of the self-encoding neural networkmodel is forwardly trained to obtain the parameter of the first hiddenlayer (W¹,b¹) through adopting a training sample without category label.When the self-encoding neural network model includes a plurality ofhidden layers, an original input vector is converted into a vectorcomposed by an activation value of a hidden unit by the first hiddenlayer. Then the vector composed by the activation value of hidden unitis used as an input vector of the second hidden layer. And the inputvector of the second hidden layer is trained to obtain the parameter ofthe second hidden layer (W²,b²). And the operation of taking an outputof a previous layer as an input of a next layer is repeatedly executedto successively train the hidden layers. When the parameter of eachlayer is trained, the parameters of remaining layers remain unchanged.It is also possible to simultaneously adjust the parameters of alllayers through the back-propagation algorithm to improve the results,after the pre-training is completed.

Operation S30: modifying the hidden feature according to a presetclassification scale and the classification requirement;

It should be noted that the classification scale generally refers to thescale between the categories. For example, a text category can bedivided into two categories, which includes the positive evaluation andthe negative evaluation. And the scale between the positive evaluationand the negative evaluation is the classification scale. Theclassification scale can be predefined or calculated from the samples.

Taking the evaluation text as an example, the evaluation can be dividedinto the positive evaluation and the negative evaluation. Theclassification scale of the i^(-th) dimension feature is expressed asL_(i)=|h_(1i)−h_(2i)|, in which h_(1i) is the average value of thehidden features of the positive evaluation sample of the i^(-th)dimension feature, and h_(2i) is the average value of the hiddenfeatures of the negative evaluation sample of the i^(-th) dimensionfeature.

Operation 540: defining the modified hidden feature as the intermediatehidden layer of the self-encoding neural network model, and reverselygenerating a word vector corresponding to an input layer of theself-encoding neural network model by the intermediate hidden layer;

It should be noted that the modified hidden feature is defined as theintermediate hidden layer of the self-encoding neural network model, anda word vector corresponding to an input layer of the self-encodingneural network model is reversely generated by the intermediate hiddenlayer. And the word vector is defined as the modified hidden feature anddecoded as the input vector of the self-encoding neural network model(Referring to FIG. 3, for example, the self-encoding neural networkmodel includes a single hidden layer, the input layer and thecorresponding word vector are obtained by decoding the hidden layer).

Operation 550: generating the corresponding text, according to thegenerated word vector.

It should be noted that the operation of “generating the correspondingtext, according to the generated word vector” is to generate a textthrough the words corresponding to the generated word vector. The textcan be generated through directly connecting the words together, or toform the text through another rules.

In a specific embodiment, the operation of “generating the correspondingtext, according to the generated word vector”, includes:

Operation 551: matching the generated word vector with a pre-trainedword vector library, and generating words each word corresponding to oneword vector;

It should be noted that the pre-trained word vector library is a libraryincluding the correspondences among the words and the word vectorsestablished in advance according to certain rules.

Operation 552: connecting the generated words together to generate thecorresponding text.

It should be noted that text may be generated by directly connecting thewords together, or by another rules.

The present disclosure obtains the text word vector and theclassification requirement of the statement to be input, and reverselyinputs the text word vector into the trained self-encoding neuralnetwork model to obtain the hidden feature of the intermediate hiddenlayer of the self-encoding neural network model. The hidden feature ismodified according to the preset classification scale and classificationrequirement. The modified hidden feature is defined as the intermediatehidden layer of the self-encoding neural network model. The word vectorcorresponding to the input layer of the self-encoding neural network isreversely generated through the intermediate hidden layer, the text isgenerated according to the generated word vector. The text generationstyle is adjusted according to the preset classification scale and theclassification requirements, without consuming a large amount of dataannotation resources and modeling resources. For example, the user canadjust the style scale of dialog of the customer service robot, such asthe positive emotions, the negative emotions, and friendliness, etc.

Referring to FIG. 4, FIG. 4 is a schematic flowchart of a method forgenerating a text based on a self-encoding neural network according to asecond embodiment of the present disclosure.

Based on the first embodiment above-mentioned, in the embodiment, beforethe operation of S10, the method includes the following operations:

Operation S101: obtaining labeled multi-category training samples, andgenerating corresponding classification word vectors;

It should be noted that the multi-category training samples refers tothat the training samples are divided into multiple categories. Takingthe evaluation text as an example, the evaluation samples are dividedinto two categories which include the positive evaluation text and thenegative evaluation text. The multi-category training samples withlabels refer to each of the multi-category training samples are labeledrespectively (for example, the labels with the positive evaluations orwith the negative evaluations).

Operation S102: forwardly inputting the classification word vectors intothe trained self-encoding neural network model forwardly to obtain thehidden features of the multi-category training samples;

It should be noted that the operation of reversely inputting the textword vector into a trained self-encoding neural network mode means thatthe text word vector is configured as the input vector of the trainedself-encoding neural network model, and the text word vector isforwardly input into the trained self-encoding neural network model toobtain the hidden feature of the intermediate hidden layer, the hiddenfeature is configured as the hidden feature of the multi-categorytraining samples (Referring to FIG. 3, FIG. 3 is the situation where theintermediate hidden layer has one hidden layer, the text word vector isinput from the output layer to obtain the hidden features of the hiddenlayer located between the input layer and the output layer). When theself-encoding neural network model has multiple layers, the hiddenfeature obtained by the middlemost hidden layer of which is taken as thehidden feature of the intermediate hidden layer. For example, when theself-encoding neural network model has three hidden layers, the hiddenfeature obtained by the second middle layer is taken as the hiddenfeature of the intermediate hidden layer; or when the self-encodingneural network model has two hidden layers, an average value of thehidden features corresponding to the two middlemost hidden layers istaken as the hidden feature of the intermediate hidden layer.

Operation S103: calculating a vector difference of the hidden featuresof the multi-category training samples, and defining the vectordifference as the classification scale of the multi-category trainingsamples.

It should be noted that the vector difference of the hidden features ofthe multi-category training samples is calculated, and the vectordifference is defined as the classification scale of the correspondingmulti-category training sample. Taking the evaluation text as anexample, the evaluation can be divided into the positive evaluation andthe negative evaluation. The classification scale of the i^(th)dimension feature is expressed as L_(i)=|h_(1i)−h_(2i)|, in which h_(1i)is the average value of the hidden features of the positive evaluationsample of the i^(th) dimension feature, h_(2i) is the average value ofthe hidden features of the negative evaluation sample of the i^(th)dimension feature.

Referring to FIG. 5, FIG. 5 is a schematic flowchart of a method forgenerating a text based on a self-encoding neural network according to athird embodiment of the present disclosure.

Based on the second embodiment above-mentioned, in the embodiment, theoperation of S30, specifically includes:

Operation S31: determining an adjustment vector corresponding to thehidden feature according to the preset classification scale and theclassification requirement;

In a specific embodiment, if the classification scale is regard as L andthe classification requirement is an output negative evaluation text,the adjustment vector b can be determined according to the degree of thenegative evaluation, and the adjustment vector b is usually adjusted.

Operation S32: modifying the hidden feature according to the adjustmentvector.

It should be noted that, the hidden feature is modified according to theadjustment vector. The adjustment vector may be configured as a vectordifference between the hidden feature and the adjustment vector, or maybe configured as a weight value, so that the modified hidden feature isoutputted according to corresponding classification demand.

Referring to FIG. 6, FIG. 6 is a schematic flowchart of a method forgenerating a text based on a self-encoding neural network according to afourth embodiment of the present disclosure.

Based on the third embodiment above-mentioned, in the embodiment, theoperation S32, specifically includes:

Operation S321: defining a vector difference between the hidden featureand the adjustment vector as the modified hidden feature.

In a specific embodiment, the hidden feature before being modified isregarded as h_(before), and the adjustment vector is regarded as b, andthe modified hidden feature satisfies a relationship:h_(before)=h_(after)−b.

Referring to FIG. 7, FIG. 7 is a schematic flowchart of a method forgenerating a text based on a self-encoding neural network according to afifth embodiment of the present disclosure.

Based on the first embodiment above-mentioned, in the embodiment, beforethe operation of S10, the method further includes:

Operation S104: establishing the self-encoding neural network model;

It should be noted that the self-encoding neural network model is anunsupervised learning neural network that reconstructs the input signalas much as possible. The self-encoding neural network model includes aplurality of intermediate hidden layers or one single intermediatehidden layer. (Referring to FIG. 3).

Operation S105: obtaining a training sample without a category label andgenerating corresponding word vector;

It should be noted that the training sample without a category labelrefers to its category is not labeled.

Operation S106: inputting the word vector forwardly, and training theself-encoding neural network model.

In a specific embodiment, a first hidden layer of the self-encodingneural network model is forwardly trained to obtain the parameter of thefirst hidden layer (W¹,b¹) through adopting a training sample withoutcategory label. When the self-encoding neural network model includes aplurality of hidden layers, an original input vector is converted into avector composed by an activation value of a hidden unit by the firsthidden layer. Then the vector composed by the activation value of hiddenunit is used as an input vector of the second hidden layer. And theinput vector of the second hidden layer is trained to obtain theparameter of the second hidden layer (W²,b²). And the operation oftaking an output of a previous layer as an input of a next layer isrepeatedly executed to successively train the hidden layers. When theparameter of each layer is trained, the parameters of remaining layersremain unchanged. It is also possible to simultaneously adjust theparameters of all layers through the back-propagation algorithm toimprove the results, after the pre-training is completed.

In addition, an embodiment of the present disclosure further provides acomputer-readable storage medium, and the computer-readable storagemedium may be a non-volatile readable storage medium.

The computer-readable instruction is stored on the computer-readablestorage medium, and the computer-readable instruction after executed bythe processor performs operations of the method for generating a textbased on a self-encoding neural network above-mentioned.

Referring to FIG. 8, FIG. 8 is a structural block diagram of a devicefor generating a text based on a self-encoding neural network accordingto a first embodiment of the present disclosure.

Referring to FIG. 8, text generating device based on a self-encodingneural network provided in the embodiment of the present disclosureincludes:

an obtaining module 801, configured to obtain a text word vector of ainput statement and of a classification requirement;

It should be noted that the classification requirement generally refersto the desired classification category. Taking an evaluation text as anexample, which can be divided into two categories that includes apositive evaluation and a negative evaluation. The classificationrequirements may be an expectation to output the negative evaluation, oran expectation to output the positive evaluation. The classificationrequirement may be obtained by user-defined input, or may be preset,which is not specifically limited herein.

In a specific embodiment, the operations of “obtaining a text wordvector of a statement to be input”, specifically includes: obtaining theinput statement, preprocessing the input statement and obtaining thetext word vector of the preprocessed input statement.

The process of preprocessing the input statement generally includes:removing a stop word. The stop word refers to a word which appearsmultiple times and has little effect on the text, such as Chinesecharacter “

”, “

”, “

”, etc., or the Hyper Text Markup Language (HTML) tag and the scriptinglanguage in the web page data set, etc.

For example, if the input text is doc, the corresponding text wordvectors are {ω1, ω2, . . . ωi}, in which oi is the word vector of thei^(th) word in the statement.

An input module 802, configured to reversely inputting the text wordvector into a trained self-encoding neural network model reversely toobtain a hidden feature of an intermediate hidden layer of theself-encoding neural network model;

It should be noted that the operation of reversely inputting the textword vector into a trained self-encoding neural network model to obtaina hidden feature of an intermediate hidden layer of the self-encodingneural network model means that the text word vector is configured asthe output vector of the trained self-encoding neural network model toobtain the hidden feature of the intermediate hidden layer reversely(Referring to FIG. 3, FIG. 3 is the situation that the self-encodingneural network model includes one hidden layer, the text word vector isinput into the output layer to obtain the hidden feature of the hiddenlayer located between the input layer and the output layer). When theself-encoding neural network model has multiple hidden layers, thehidden feature obtained of the middlemost hidden layer is taken as thehidden feature of the intermediate hidden layer. For example, when theself-encoding neural network model has three hidden layers, the hiddenfeature obtained by the second middle layer is taken as the hiddenfeature of the intermediate hidden layer; or when the intermediatehidden layers has two hidden layers, an average value of the hiddenfeatures corresponding to the two hidden layers is taken as the hiddenfeature of the intermediate hidden layer.

In a specific embodiment, the training process of the self-encodingneural network model includes:

Pre-training, a first hidden layer of the self-encoding neural networkmodel is forwardly trained to obtain the parameter of the first hiddenlayer (W¹,b¹) through adopting a training sample without category label.When the self-encoding neural network model includes a plurality ofhidden layers, an original input vector is converted into a vectorcomposed by an activation value of a hidden unit by the first hiddenlayer. Then the vector composed by the activation value of hidden unitis used as an input vector of the second hidden layer. And the inputvector of the second hidden layer is trained to obtain the parameter ofthe second hidden layer (W²,b²). And the operation of taking an outputof a previous layer as an input of a next layer is repeatedly executedto successively train the hidden layers. When the parameter of eachlayer is trained, the parameters of remaining layers remain unchanged.It is also possible to simultaneously adjust the parameters of alllayers through the back-propagation algorithm to improve the results,after the pre-training is completed.

A modifying module 803, configured to modify the hidden featureaccording to a preset classification scale and the classificationrequirement;

It should be noted that the classification scale generally refers to thescale between the categories. For example, a text category can bedivided into two categories, which includes the positive evaluation andthe negative evaluation. And the scale between the positive evaluationand the negative evaluation is the classification scale. Theclassification scale can be predefined or calculated from the samples.

Taking the evaluation text as an example, the evaluation can be dividedinto the positive evaluation and the negative evaluation. Theclassification scale of the i^(-th) dimension feature is expressed asL_(i)=|h_(1i)−h_(2i)|, in which h_(1i) is the average value of thehidden features of the positive evaluation sample of the i^(-th)dimension feature, and h_(2i) is the average value of the hiddenfeatures of the negative evaluation sample of the i^(-th) dimensionfeature.

A decoding module 804, configured to define the modified hidden featureas the intermediate hidden layer of the self-encoding neural networkmodel, and reversely generating a word vector corresponding to an inputlayer of the self-encoding neural network model by the intermediatehidden layer;

It should be noted that the modified hidden feature is defined as theintermediate hidden layer of the self-encoding neural network model, anda word vector corresponding to an input layer of the self-encodingneural network model is reversely generated by the intermediate hiddenlayer. And the word vector is defined as the modified hidden feature anddecoded as the input vector of the self-encoding neural network model(Referring to FIG. 3, for example, the self-encoding neural networkmodel includes a single hidden layer, the input layer and thecorresponding word vector are obtained by decoding the hidden layer).

A generating module 805, configured to generate the corresponding text,according to the generated word vector.

It should be noted that the operation of “generating the correspondingtext, according to the generated word vector” is to generate a textthrough the words corresponding to the generated word vector. The textcan be generated through directly connecting the words together, or toform the text through another rules.

The present disclosure obtains the text word vector and theclassification requirement of the statement to be input, and reverselyinputs the text word vector into the trained self-encoding neuralnetwork model to obtain the hidden feature of the intermediate hiddenlayer of the self-encoding neural network model. The hidden feature ismodified according to the preset classification scale and classificationrequirement. The modified hidden feature is defined as the intermediatehidden layer of the self-encoding neural network model. The word vectorcorresponding to the input layer of the self-encoding neural network isreversely generated through the intermediate hidden layer, the text isgenerated according to the generated word vector. And the textgeneration style is adjusted by the preset classification scales and theclassification needs, without consuming a large amount of dataannotation resources and modeling resources. For example, the user canadjust the style scale of the customer service robot's dialog. And thestyle scale, such as the positive emotions, the negative emotions, andfriendliness, etc.

The other embodiments or specific implementations of the text generatingdevice based on the self-encoding neural network of the presentdisclosure refer to the embodiments of the method above-mentioned, andthe details are not described herein.

It needs to be noted that in the present disclosure, the terms“comprising”, “including” or other variants aim to cover non-exclusiveinclusion, such that the processes, methods, articles or devicesincluding a series of factors not only include these factors, but alsoinclude other factors not listed explicitly, or further comprise includeintrinsic for such processes, methods, articles or devices. In theabsence of more limitations, the factors limited by “comprising a . . .” do not exclude that additional identical factors are also included inthe processes, methods, articles or devices comprising said factors.

The sequence number in the above embodiments of the present disclosureis only for the purpose of explanation and not intended to indicate themerits of the embodiments.

Through above description of the embodiments, it should be understood bya person skilled in the art that the present disclosure may beimplemented by means of software in connection with necessary universalhardware platform. Of course, the present disclosure may also beimplemented by a hardware. However, in many cases the former is morepreferred. Based on this understanding, all or the part contributing tothe prior art of the technical solution of the present disclosure may beembodied in the form of software. The computer software may be stored ona storage medium (such as ROM/RAM, diskette, or light disk) and includea plurality of instructions which are used to implement the method asdescribed in the various embodiments of the present disclosure by aterminal device (such as a mobile phone, a computer, a server, an airconditioner, or a network device, etc.)

The foregoing description merely depicts some embodiments of the presentapplication and therefore is not intended to limit the scope of theapplication. An equivalent structural or flow changes made by using thecontent of the specification and drawings of the present application, orany direct or indirect applications of the disclosure on any otherrelated fields shall all fall in the scope of the application.

1. A method for generating a text based on a self-encoding neuralnetwork, comprising: obtaining a text word vector and a classificationrequirement of a statement to be input; reversely inputting the textword vector into a trained self-encoding neural network model to obtaina hidden feature of an intermediate hidden layer of the self-encodingneural network model; modifying the hidden feature according to a presetclassification scale and the classification requirement; defining themodified hidden feature as the intermediate hidden layer of theself-encoding neural network model, and reversely generating a wordvector corresponding to an input layer of the self-encoding neuralnetwork model by the intermediate hidden layer; and generating thecorresponding text, according to the generated word vector.
 2. Themethod according to claim 1, wherein before the operation of “obtaininga text word vector and a classification requirement of a statement to beinput”, comprises: obtaining labeled multi-category training samples,and generating corresponding classification word vectors; forwardlyinputting the classification word vectors into the trained self-encodingneural network model to obtain hidden features of the multi-categorytraining samples; and calculating a vector difference of the hiddenfeatures of the multi-category training samples, and defining the vectordifference as the classification scale of the multi-category trainingsamples.
 3. The method according to claim 2, wherein the operation of“modifying the hidden feature according to a preset classification scaleand the classification requirement”, comprises: determining anadjustment vector corresponding to the hidden feature according to thepreset classification scale and the classification requirement; andmodifying the hidden feature according to the adjustment vector.
 4. Themethod according to claim 3, wherein the operation of “modifying thehidden feature according to the adjustment vector”, comprises: defininga vector difference between the hidden feature and the adjustment vectoras the modified hidden feature, and wherein the hidden feature beforebeing modified is regarded as h_(before), the adjustment vector isregarded as b, and the modified hidden feature satisfies a relationship:h_(before)=h_(after)−b.
 5. The method according to claim 1, wherein inresponse to a determination that the self-encoding neural network modelcomprises a plurality of intermediate hidden layers, the operation of“reversely inputting the text word vector into a trained self-encodingneural network model to obtain a hidden feature of an intermediatehidden layer of the self-encoding neural network model”, comprises:inputting the text word vector into an output layer of the trainedself-encoding neural network model, and inversely generating a hiddenfeature of the intermediate hidden layer of the self-encoding neuralnetwork model by the output layer, and defining the hidden feature asthe hidden feature of the intermediate hidden layer of the self-encodingneural network model; and taking a hidden feature corresponding to amiddlemost layer of the intermediate hidden layers as the hidden featureof the intermediate hidden layer of the self-encoding neural networkmodel, in response to a determination that the self-encoding neuralnetwork model comprises an odd number of intermediate hidden layers; ortaking an average value of the hidden features corresponding to twomiddlemost layers of the intermediate hidden layers as the hiddenfeature of the intermediate hidden layer of the self-encoding neuralnetwork model, in response to a determination that the self-encodingneural network model comprises an even number of intermediate hiddenlayers.
 6. The method according to claim 1, wherein before the operationof “obtaining a text word vector and a classification requirement of astatement to be input”, comprises: establishing the self-encoding neuralnetwork model; obtaining a training sample without a category label andgenerating corresponding word vector; inputting the word vectorforwardly, and training the self-encoding neural network model; whereinthe operation of “training the self-encoding neural network model”,comprises: forwardly inputting the word vector, forwardly training afirst hidden layer of the self-encoding neural network model; inresponse to a determination that the self-encoding neural network modelcomprises a plurality of hidden layers, converting an original vectorinput into the self-encoding neural network model into a vector composedby an activation value of a hidden unit by the first hidden layer;defining the vector as an input vector of a second hidden layer;training the input vector of the second hidden layer to obtain aparameter of the second hidden layer; successively training the hiddenlayers by repeatedly defining an output vector of a previous layer as aninput vector of a next layer; and in response to training the parameterof each hidden layer, remaining the parameters of remaining layersunchanged.
 7. The method according to claim 1, wherein the operation of“generating the corresponding text, according to the generated wordvector”, comprises: matching the generated word vector with apre-trained word vector library, and generating words each wordcorresponding to one word vector; and connecting the generated wordstogether to generate the corresponding text.
 8. (canceled)
 9. Aterminal, comprising: a processor, a memory, and a computer-readableinstruction for generating a text based on a self-encoding neuralnetwork, the instruction being stored on the memory and executable onthe processor, the instruction being configured to implement followingoperations: obtaining a text word vector and a classificationrequirement of a statement to be input; reversely inputting the textword vector into a trained self-encoding neural network model to obtaina hidden feature of an intermediate hidden layer of the self-encodingneural network model; modifying the hidden feature according to a presetclassification scale and the classification requirement; defining themodified hidden feature as the intermediate hidden layer of theself-encoding neural network model, and reversely generating a wordvector corresponding to an input layer of the self-encoding neuralnetwork model by the intermediate hidden layer; and generating thecorresponding text, according to the generated word vector.
 10. Theterminal according to claim 9, wherein before the operation of“obtaining a text word vector and a classification requirement of astatement to be input”, comprises: obtaining labeled multi-categorytraining samples, and generating corresponding classification wordvectors; forwardly inputting the classification word vectors into thetrained self-encoding neural network model to obtain hidden features ofthe multi-category training samples; and calculating a vector differenceof the hidden features of the multi-category training samples, anddefining the vector difference as the classification scale of themulti-category training samples.
 11. The terminal according to claim 10,wherein the operation of “modifying the hidden feature according to apreset classification scale and the classification requirement”,comprises: determining an adjustment vector corresponding to the hiddenfeature according to the preset classification scale and theclassification requirement; and modifying the hidden feature accordingto the adjustment vector.
 12. The terminal according to claim 11,wherein the operation of “modifying the hidden feature according to theadjustment vector”, comprises: defining a vector difference between thehidden feature and the adjustment vector as the modified hidden feature,and wherein the hidden feature before being modified is regarded ash_(before), the adjustment vector is regarded as b, and the modifiedhidden feature satisfies a relationship: h_(before)=h_(after)−b.
 13. Theterminal according to claim 9, wherein in response to a determinationthat the self-encoding neural network model comprises a plurality ofintermediate hidden layers, the operation of “reversely inputting thetext word vector into a trained self-encoding neural network model toobtain a hidden feature of an intermediate hidden layer of theself-encoding neural network model”, comprises: inputting the text wordvector into an output layer of the trained self-encoding neural networkmodel, and inversely generating a hidden feature of the intermediatehidden layer of the self-encoding neural network model by the outputlayer, and defining the hidden feature as the hidden feature of theintermediate hidden layer of the self-encoding neural network model; andtaking a hidden feature corresponding to a middlemost layer of theintermediate hidden layers as the hidden feature of the intermediatehidden layer of the self-encoding neural network model, in response to adetermination that the self-encoding neural network model comprises anodd number of intermediate hidden layers; or taking an average value ofthe hidden features corresponding to two middlemost layers of theintermediate hidden layers as the hidden feature of the intermediatehidden layer of the self-encoding neural network model, in response to adetermination that the self-encoding neural network model comprises aneven number of intermediate hidden layers.
 14. The terminal according toclaim 9, wherein before the operation of “obtaining a text word vectorand a classification requirement of a statement to be input”, comprises:establishing the self-encoding neural network model; obtaining atraining sample without a category label and generating correspondingword vector; inputting the word vector forwardly, and training theself-encoding neural network model; wherein the operation of “trainingthe self-encoding neural network model”, comprises: forwardly inputtingthe word vector, forwardly training a first hidden layer of theself-encoding neural network model; in response to a determination thatthe self-encoding neural network model comprises a plurality of hiddenlayers, converting an original vector input into the self-encodingneural network model into a vector composed by an activation value of ahidden unit by the first hidden layer; defining the vector as an inputvector of a second hidden layer; training the input vector of the secondhidden layer to obtain a parameter of the second hidden layer;successively training the hidden layers by repeatedly defining an outputvector of a previous layer as an input vector of a next layer; and inresponse to training the parameter of each hidden layer, remaining theparameters of remaining layers unchanged.
 15. The terminal according toclaim 9, wherein the operation of “generating the corresponding text,according to the generated word vector”, comprises: matching thegenerated word vector with a pre-trained word vector library, andgenerating words each word corresponding to one word vector; andconnecting the generated words together to generate the correspondingtext.
 16. A computer-readable storage medium, storing acomputer-readable instruction for generating a text based on aself-encoding neural network, and the instruction implementing followingoperations when being executed by a processor: obtaining a text wordvector and a classification requirement of a statement to be input;reversely inputting the text word vector into a trained self-encodingneural network model to obtain a hidden feature of an intermediatehidden layer of the self-encoding neural network model; modifying thehidden feature according to a preset classification scale and theclassification requirement; defining the modified hidden feature as theintermediate hidden layer of the self-encoding neural network model, andreversely generating a word vector corresponding to an input layer ofthe self-encoding neural network model by the intermediate hidden layer;and generating the corresponding text, according to the generated wordvector.
 17. The computer-readable storage medium according to claim 16,wherein before the operation of “obtaining a text word vector and aclassification requirement of a statement to be input”, comprises:obtaining labeled multi-category training samples, and generatingcorresponding classification word vectors; forwardly inputting theclassification word vectors into the trained self-encoding neuralnetwork model to obtain hidden features of the multi-category trainingsamples; and calculating a vector difference of the hidden features ofthe multi-category training samples, and defining the vector differenceas the classification scale of the multi-category training samples. 18.The computer-readable storage medium of claim 17, wherein the operationof “modifying the hidden feature according to a preset classificationscale and the classification requirement”, comprises: determining anadjustment vector corresponding to the hidden feature according to thepreset classification scale and the classification requirement; andmodifying the hidden feature according to the adjustment vector.
 19. Thecomputer-readable storage medium of claim 18, wherein the operation of“modifying the hidden feature according to the adjustment vector”,comprises: defining a vector difference between the hidden feature andthe adjustment vector as the modified hidden feature, and wherein thehidden feature before being modified is regarded as h_(before), theadjustment vector is regarded as b, and the modified hidden featuresatisfies a relationship: h_(before)=h_(after)−b.
 20. Thecomputer-readable storage medium of claim 16, wherein in response to adetermination that the self-encoding neural network model comprises aplurality of intermediate hidden layers, the operation of “reverselyinputting the text word vector into a trained self-encoding neuralnetwork model to obtain a hidden feature of an intermediate hidden layerof the self-encoding neural network model”, comprises: inputting thetext word vector into an output layer of the trained self-encodingneural network model, and inversely generating a hidden feature of theintermediate hidden layer of the self-encoding neural network model bythe output layer, and defining the hidden feature as the hidden featureof the intermediate hidden layer of the self-encoding neural networkmodel; and taking a hidden feature corresponding to a middlemost layerof the intermediate hidden layers as the hidden feature of theintermediate hidden layer of the self-encoding neural network model, inresponse to a determination that the self-encoding neural network modelcomprises an odd number of intermediate hidden layers; or taking anaverage value of the hidden features corresponding to two middlemostlayers of the intermediate hidden layers as the hidden feature of theintermediate hidden layer of the self-encoding neural network model, inresponse to a determination that the self-encoding neural network modelcomprises an even number of intermediate hidden layers.
 21. Thecomputer-readable storage medium of claim 16, wherein before theoperation of “obtaining a text word vector and a classificationrequirement of a statement to be input”, comprises: establishing theself-encoding neural network model; obtaining a training sample withouta category label and generating corresponding word vector; inputting theword vector forwardly, and training the self-encoding neural networkmodel; wherein the operation of “training the self-encoding neuralnetwork model”, comprises: forwardly inputting the word vector,forwardly training a first hidden layer of the self-encoding neuralnetwork model; in response to a determination that the self-encodingneural network model comprises a plurality of hidden layers, convertingan original vector input into the self-encoding neural network modelinto a vector composed by an activation value of a hidden unit by thefirst hidden layer; defining the vector as an input vector of a secondhidden layer; training the input vector of the second hidden layer toobtain a parameter of the second hidden layer; successively training thehidden layers by repeatedly defining an output vector of a previouslayer as an input vector of a next layer; and in response to trainingthe parameter of each hidden layer, remaining the parameters ofremaining layers unchanged.